/*
 * (C) Copyright 2011
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <command.h>
#include <rtc.h>

#include "asm/yams.h"

#if defined(CONFIG_CMD_DATE)

/* The structure of the YAMS RTC IO area */
typedef struct {
    uint32_t msec;    /* Milliseconds elapsed since the machine started */
    uint32_t clkspd;  /* Machine clock speed in HZ */
} rtc_io_area_t;

volatile rtc_io_area_t *yams_rtc_iobase;

void rtc_init(void)
{
	return;
}


void rtc_reset(void)
{
	return;
}

/*
 * Set the RTC
*/
int rtc_set(struct rtc_time *tmp)
{
	return 0;
}

/*
 * Get the current time from the RTC
 */
int rtc_get(struct rtc_time *tmp)
{
    io_descriptor_t *io_desc;

    io_desc = (io_descriptor_t *)IO_DESCRIPTOR_AREA;
    
    while(io_desc->type != 0) {
        if (io_desc->type == 0x102) {
            yams_rtc_iobase = (rtc_io_area_t *) io_desc->io_area_base;
			printf("YAMS MIPS CPU(s) with virtual clock rate %d Hz\n", yams_rtc_iobase->clkspd);
			printf("Running time:%d ms(No relatioin whatsoever with real word time)\n", yams_rtc_iobase->msec);
            break;
        }
        io_desc++;
    }

	return 0;
}

#endif

